const express = require('express')
const bodyparser = require('body-parser')
const cookieparser = require('cookie-parser')
const cookieSesstion = require('cookie-session')
const app = express()



/**
 * 发送Cookie
 * res.secret = 'asdf8asdfj2' 签名
 * res.cookie(名字， 值， {path: '/', maxAge: 毫秒，signed: true})
 * 
 * 读取Cookie
 * cookieparser
 * app.use(cookieparser(签名))
 * 
 * req.cookies 未签名
 * req.signedCookie 已签名
 * 
 * 删除Cookie
 * res.clearCookie(name)
 * 
 * 
 * 
 * cookie-sesstion
 * app.use(cookieparser())
 * app.use(cookieSesstion({
 *      keys: [...,...,...]     
 * }))
 * 
 * 使用 
 * req.session
 * 删除
 * delete req.session
 * 
 */

app.use(cookieparser())
app.use(bodyparser.urlencoded({
    extended: false,
    limit: 2*1024*1024
}))

app.use('/', function(req, res, next) {
    console.log(req.cookies)
    console.log(req.body)
    next()
})

app.use('/', function(req, res, next) {
    console.log(2);
})

app.listen(8080)